Skip to content

Add SILK noise shaping quantizer#164

Merged
thomas-vilte merged 1 commit into
pion:mainfrom
thomas-vilte:feat/silk-nsq
Jul 23, 2026
Merged

Add SILK noise shaping quantizer#164
thomas-vilte merged 1 commit into
pion:mainfrom
thomas-vilte:feat/silk-nsq

Conversation

@thomas-vilte

Copy link
Copy Markdown
Member

Description

adds the non-delayed-decision noise-shaping quantizer (silk_NSQ_c, NSQ.c) — the core of the SILK encoder: short- and long-term prediction plus noise shaping applied to the scaled input, quantized to integer excitation pulses. Includes the state-scaling step (gain changes, LTP re-whitening) and the fixed-point LPC residual filter used for re-whitening

ported from NSQ.c, NSQ.h, and LPC_analysis_filter.c

found one real bug while reviewing — not introduced during this split, it's in the original code, byte-identical extraction: PredCoef_Q12 is indexed with a stride of maxLPCOrder (24, matching SILK_MAX_ORDER_LPC — a different, oversized constant used by the Schur/k2a analysis math), but libopus lays that buffer out in strides of MAX_LPC_ORDER (16, define.h) — a distinct constant with a coincidentally-related name. It didn't show up in the existing smoke test because the test builds its own predCoefQ12 buffer with the same (wrong) stride, so both sides were self-consistently wrong. It would only have broken once a real caller supplied a correctly-16-strided buffer in a later piece. Added maxPredictLPCOrder = 16 and fixed both the indexing and the (harmless but also mislabeled) internal buffer-size constant

also added a voiced-signal test — the original only covered the unvoiced path, so lpcAnalysisFilterFixed (the re-whitening filter) had zero coverage, and neither the LTP prediction nor the aggressive-RDO branch (lambdaQ10>2048) were reachable. Both files are at 100% coverage now

Reference issue

part of the SILK encoder series (#161).

Co-authored-by: François Allais <francois.allais@hotmail.com>
@codecov

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.61%. Comparing base (a3150b6) to head (96984db).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #164      +/-   ##
==========================================
+ Coverage   89.35%   89.61%   +0.25%     
==========================================
  Files          47       48       +1     
  Lines        8851     9049     +198     
==========================================
+ Hits         7909     8109     +200     
+ Misses        707      706       -1     
+ Partials      235      234       -1     
Flag Coverage Δ
go 89.61% <100.00%> (+0.25%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@thomas-vilte
thomas-vilte requested a review from FrantaBOT July 23, 2026 16:15
@thomas-vilte
thomas-vilte merged commit 9291bd6 into pion:main Jul 23, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants